package com.homework.action;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.homework.bean.HomeworkBean;
import com.homework.bean.UserSimilarityBean;
import com.homework.bean.UserSimilarityListBean;
import com.homework.service.HomeworkService;
import com.opensymphony.xwork2.ActionSupport;

public class SelectSimilarityAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	HomeworkService homeworkService = new HomeworkService();
	private String batch;
	private String courseId;
	UserSimilarityListBean userSimilarityListBean;
	private List<String> batchList;
	
	
	public String execute() throws NumberFormatException, SQLException{
		
		userSimilarityListBean =  new UserSimilarityListBean();
		List<UserSimilarityBean> userSimilarity = new ArrayList<UserSimilarityBean>();
			
		HomeworkBean homeworkBean = new HomeworkBean();
		homeworkBean.setBatch(getBatch());
		
		//动态获取batch
		batchList = new ArrayList<String>();
		int num = homeworkService.getBatchNum(courseId);
		for (int i = 1; i <= num; i++) {
			batchList.add(String.valueOf(i));
			} 
		
		homeworkService.getHomeworkInfo(userSimilarity,courseId,homeworkBean);		
		userSimilarityListBean.setUserSimilarity(userSimilarity);
		
		return SUCCESS;
	}
	
	
	
	public UserSimilarityListBean getUserSimilarityListBean() {
		return userSimilarityListBean;
	}

	public void setUserSimilarityListBean(
			UserSimilarityListBean userSimilarityListBean) {
		this.userSimilarityListBean = userSimilarityListBean;
	}

	public String getBatch() {
		return batch;
	}
	public void setBatch(String batch) {
		this.batch = batch;
	}
	public String getCourseId() {
		return courseId;
	}
	public void setCourseId(String courseId) {
		this.courseId = courseId;
	}
	public List<String> getBatchList() {
		return batchList;
	}



	public void setBatchList(List<String> batchList) {
		this.batchList = batchList;
	}
	

}
